//
//  QDetailPeopleCell.m
//  QoilPublic
//
//  Created by 杨凯 on 16/12/20.
//  Copyright © 2016年 杨凯. All rights reserved.
//

#import "QDetailPeopleCell.h"

@interface QDetailPeopleCell()




@end

@implementation QDetailPeopleCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setModel:(QAllorderListModel *)model{
    _model = model;
    
    if(_isSend == YES){//地图那边过来的
        if(_indexPath.section == 3 && _indexPath.row == 0){
            if([_model.orderPeople isEqualToString:@"1"]){//下单人
                 _titleLabel.text = @"代付人姓名";
                 _subLabel.text = _model.draweeName;
                 _callBtn.hidden = YES;
            }else if([_model.orderPeople isEqualToString:@"2"]){
                _titleLabel.text = @"下单人姓名";
                _subLabel.text = _model.name;
                _callBtn.hidden = YES;
            }else{
                _titleLabel.text = @"下单人姓名";
                _subLabel.text = _model.name;
                _callBtn.hidden = YES;
            }
            
        }else if (_indexPath.section == 3 && _indexPath.row == 1){
            if([_model.orderPeople isEqualToString:@"1"]){//下单人
                _titleLabel.text = @"代付人电话";
                _subLabel.text = _model.draweeTel;
                _callBtn.hidden = NO;
            }else if([_model.orderPeople isEqualToString:@"2"]){
                _titleLabel.text = @"下单人电话";
                _subLabel.text = _model.userTel;
                _callBtn.hidden = NO;
            }else{
                _titleLabel.text = @"下单人电话";
                _subLabel.text = _model.userTel;
                _callBtn.hidden = NO;
            }
        }
    }else{
        if(_indexPath.section == 4 && _indexPath.row == 0){
            if([_model.orderPeople isEqualToString:@"1"]){//下单人
                _titleLabel.text = @"代付人姓名";
                _subLabel.text = _model.draweeName;
                _callBtn.hidden = YES;
            }else if([_model.orderPeople isEqualToString:@"2"]){
                _titleLabel.text = @"下单人姓名";
                _subLabel.text = _model.userName;
                _callBtn.hidden = YES;
            }else{
                _titleLabel.text = @"下单人姓名";
                _subLabel.text = _model.userName;
                _callBtn.hidden = YES;
            }
        }else if (_indexPath.section == 4 && _indexPath.row == 1){
            if([_model.orderPeople isEqualToString:@"1"]){//下单人
                _titleLabel.text = @"代付人电话";
                _subLabel.text = _model.draweeTel;
                _callBtn.hidden = NO;
            }else if([_model.orderPeople isEqualToString:@"2"]){
                _titleLabel.text = @"下单人电话";
                _subLabel.text = _model.userTel;
                _callBtn.hidden = NO;
            }else{
                _titleLabel.text = @"下单人电话";
                _subLabel.text = _model.userTel;
                _callBtn.hidden = NO;
            }
        }
    }
}

- (void)setIndexPath:(NSIndexPath *)indexPath{

    _indexPath = indexPath;
    _subLabel.textColor = [QColorUtility defaultDeepGrayColor];
    
}

- (IBAction)callAction:(id)sender {
    
    [QViewUtility showPlayBoxView:playboxPeoplePayOrderStyle myBlock:^(NSInteger index) {
        if(index == 1){
            if([_model.orderPeople isEqualToString:@"1"]){//下单人
            
                NSURL *url=[NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@",_model.draweeTel]];
                [[UIApplication sharedApplication]openURL:url];

            }else{
                NSURL *url=[NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@",_model.userTel]];
                [[UIApplication sharedApplication]openURL:url];
            }
        }
    }];
}



@end
